using System;
using System.Collections.Generic;
using System.Text;

namespace GameOfLife
{
    public class RuleSet
    {
	private int[] dead2alive;
	private int[] alive2alive;

        /// <summary>
        /// The constructor for Ruleset
        /// 
        ///  the parameters specify the number of neighbors
        ///   that will transition to a living cell
        ///   during the next time step
        /// 
        ///   For example Conway's rules would be constructed
        ///    with:
        /// 
        ///    A Dead cell with 3 living neighbors
        ///    A living cell with 2 living neighbors
        ///    A living cell with 3 living neighbors 
        ///    
        ///    new RuleSet(new int[1] { 3 }, new int[2] { 2, 3 })
        /// 
        /// </summary>
        /// <param name="dead2alive"></param>
        /// <param name="alive2alive"></param>
        public RuleSet(int[] dead2alive, int[] alive2alive){
		this.dead2alive=dead2alive;
		this.alive2alive=alive2alive;
        }


        /// <summary>
        /// This method is called to determine if a cell should be alive
        ///  during the next time step.
        /// </summary>
        /// <param name="isAlive">true if the cell is currently alive, false if dead</param>
        /// <param name="numNeighbors">the number of living neighbors adjacent to the cell</param>
        /// <returns></returns>
        public bool NextState(bool isAlive, int numNeighbors){
		if(isAlive){
			//Code to determine if a cell should stay alive
			foreach(int i in alive2alive){
				if(i==numNeighbors) return true;
			}
			return false;
		}else{
			//code to determine if a new cell should be created
			foreach(int i in dead2alive){
				if(i==numNeighbors) return true;
			}
			return false;
		}
        }
    }
}
